package com.spx.chapter05.transform;

import com.spx.chapter05.pojo.Event;
import com.spx.util.SampleDataUtil;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * create by undeRdoG on  2022-04-30  13:58
 * 凡心所向，素履以往，生如逆旅，一苇以航。
 */
public class FilterTest {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        DataStreamSource<Event> dataSource = env.fromCollection(SampleDataUtil.getSample());

        // 返回user以s开头的
        SingleOutputStreamOperator<Event> result = dataSource.filter(event -> event.user.startsWith("s"));

        result.print();

        env.execute();
    }
}
